/*
 * Copyright 2010. 
 * 
 * This document may not be reproduced, distributed or used 
 * in any manner whatsoever without the expressed written 
 * permission of xrkol Corp. 
 * 
 * $Rev: Rev $
 * $Author: Author $
 * $LastChangedDate: LastChangedDate $
 *
 */

package com.xrkol.sharelib.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xrkol.sharelib.dao.ShareFileDao;
import com.xrkol.sharelib.entity.ShareFile;

/**
 * @author peng.xia
 *
 */
@Repository
public class ShareFileDaoImpl extends BaseDaoImpl<ShareFile, String> implements ShareFileDao{

    @Override
    public ShareFile getLastRecordByTeacherId(String id) {
        String queryString = "from ShareFile s where s.teacherId=? order by s.createTime desc limit 1";
        List<ShareFile> shareFiles = executeQueryWithoutPaging(queryString,id);
        return shareFiles.isEmpty() ? null : shareFiles.get(0);
    }

    @Override
    public List<ShareFile> getShareFilesByPage(Integer page) {
        String queryString = "from ShareFile s";
        return executeQueryWithPagination(queryString, " order by s.createTime desc", page);
    }

}
